package main

import (
	"fmt"
	"log"
	"net/rpc"
	"os"
)

type Args struct {
	A, B int
}
type Quotient struct {
	Quo, Rem int
}

func main() {
	if len(os.Args) != 2 {
		fmt.Println("Usage:", os.Args[0], "server:port")
		os.Exit(1)
	}
	service := os.Args[1]
	client, err := rpc.Dial("tcp", service)
	if err != nil {
		log.Fatal("dialing:", err)

	}
	args := Args{28, 3}
	var reply int
	err = client.Call("Arith.Multiply", args, &reply)
	if err != nil {
		fmt.Println("Multiply err:", err.Error())
		os.Exit(1)
	}
	fmt.Printf("res %d * %d = %d\n", args.A, args.B, reply)
	var quo Quotient
	err = client.Call("Arith.Divide", args, &quo)
	if err != nil {
		fmt.Println("Divide", err.Error())
	}
	fmt.Printf("Divied: Quo:%d,Rem:%d\n", quo.Quo, quo.Rem)
}
